home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / dev / misc / gms_dev.lha / GMS / Source / C / Screens / Mirror.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-09  |  2.5 KB  |  81 lines

  1. /*
  2. ** Name:      Mirror Demo
  3. ** Author:    Paul Manias
  4. ** Copyright: DreamWorld Productions, (c) 1996-1997
  5. ** SAS/C:     1> sc Mirror.c link startup=LIB:gms.o data=far nostackcheck
  6. ** Dice:      1> dcc -l0 -mD gms.o Mirror.c -o Mirror
  7. **
  8. ** Demo of the mirroring effect.  When this effect is combined with a
  9. ** decrease in palette values at the same line, you can create the illusion of
  10. ** water.  Use the mouse to move the mirror around. LMB exits.
  11. **
  12. */
  13.  
  14. #include <proto/games.h>
  15.  
  16. extern struct GMSBase *GMSBase;
  17. ULONG PREFSNAME = DEFAULT;
  18.  
  19. ULONG WaterPalette[] = {
  20.   0x000000,0x001000,0x706050,0x705040,0x604040,0x403020,0x302020,0x100000,
  21.   0x200000,0x202020,0x707000,0x201010,0x606000,0x002000,0x200000,0x404000,
  22.   0x103000,0x103000,0x104010,0x204010,0x205010,0x205020,0x303030,0x306020,
  23.   0x304040,0x405050,0x606060,0x400000,0x400000,0x500010,0x300000,0x300000
  24. };
  25.  
  26. ULONG Rasterlist[] = {
  27.   WAITLINE(190),
  28.   MIRROR,
  29.   NEWPALETTE(0,32,WaterPalette),
  30.   RASTEND
  31. };
  32.  
  33. void main(void)
  34. {
  35.   struct GameScreen *GameScreen;
  36.   struct Picture *MirrorPic;
  37.   ULONG  mouse;
  38.   WORD   maxX,maxY;
  39.  
  40.   if (MirrorPic = LoadPicFile("GMS:demos/data/PIC.Green",VIDEOMEM|GETPALETTE)) {
  41.  
  42.      if (GameScreen = AddScreenTags(TAGS_GAMESCREEN,NULL,
  43.           GSA_MemPtr1,    MirrorPic->Data,
  44.           GSA_Palette,    MirrorPic->Palette,
  45.           GSA_Rasterlist, Rasterlist,
  46.           GSA_ScrWidth,   MirrorPic->ScrWidth,
  47.           GSA_ScrHeight,  MirrorPic->ScrHeight,
  48.           GSA_PicWidth,   MirrorPic->Width,
  49.           GSA_PicHeight,  MirrorPic->Height,
  50.           GSA_Planes,     MirrorPic->Planes,
  51.           GSA_AmtColours, MirrorPic->AmtColours,
  52.           GSA_Attrib,     HSCROLL|VSCROLL,
  53.           GSA_ScrMode,    MirrorPic->ScrMode,
  54.           GSA_ScrType,    MirrorPic->ScrType,
  55.           TAGEND)) {
  56.  
  57.        ShowScreen(GameScreen);
  58.        InitJoyPorts();
  59.  
  60.        maxX = (GameScreen->PicWidth)-(GameScreen->ScrWidth);
  61.        maxY = (GameScreen->PicHeight)-(GameScreen->ScrHeight);
  62.  
  63.        do {
  64.           mouse = ReadJoyPort(JPORT1,JT_ZBXY);
  65.           GameScreen->PicXOffset += GetX(mouse);
  66.           GameScreen->PicYOffset += GetY(mouse);
  67.           if (GameScreen->PicXOffset < 0) GameScreen->PicXOffset = 0;
  68.           if (GameScreen->PicXOffset > maxX) GameScreen->PicXOffset = maxX;
  69.           if (GameScreen->PicYOffset < 0) GameScreen->PicYOffset = 0;
  70.           if (GameScreen->PicYOffset > maxY) GameScreen->PicYOffset = maxY;
  71.           MovePicture(GameScreen);
  72.           WaitVBL();
  73.        } while (!(mouse & MB_LMB));
  74.  
  75.      DeleteScreen(GameScreen);
  76.      }
  77.   FreePic(MirrorPic);
  78.   }
  79. }
  80.  
  81.